﻿using DevExpress.XtraEditors;
using DLL;
using NursingFormSystem.Model;
using SQLDLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Common;
using NursingFormSystem.NurFormsService;
using NursingFormSystem.Common;
using ShiftProject.Scale;
using NursingFormSystem.RiskAssessment;
using System.Threading;
using NursingDocumentInfoSystem;

namespace NursingFormSystem
{
    public partial class Form1 : XtraForm
    {
        #region 变量声明
        NursingFormSystem.NurFormsService.NursingForm formService = new NursingFormSystem.NurFormsService.NursingForm();
        NursingFormRecord record = new NursingFormRecord();
        string[] Patientinfo;
        string[] UserParm;
        ElectronicSignature es;
        Tb_User LoginUser;
        #endregion

        #region 窗体构造函数
        public Form1(string[] userParm, string[] patientInfo)
        {
            InitializeComponent();
            //成员变量赋值
            this.UserParm = userParm;
            this.Patientinfo = patientInfo;

            //电签
            InitLoginUser(UserParm);
            es = new ElectronicSignature(LoginUser);//电签实例化

            //绑定数据
            BindControl();
            GetDDLSource();
        }

        private void BindControl()
        {
            if (this.Patientinfo[0] == null) return;
            #region 表头带入的数据
            txtName.Text = this.Patientinfo[2] + "";//姓名
            ddlSex.SelectedItem = this.Patientinfo[3] + "";//性别
            txtAge.Text = this.Patientinfo[4] + "";//年龄
            txtBedNo.Text = this.Patientinfo[5] + "";//床号
            txtArea.Text = this.Patientinfo[11] + "";//病区
            txtDepartment.Text = this.Patientinfo[9] + "";//科室
            txtPatientId.Text = this.Patientinfo[0] + "";//病案号
            ddlNationals.Text = this.Patientinfo[12] + "";//民族
            ddlEducation.Text = this.Patientinfo[13] + "";//文化程度
            ddlJob.Text = this.Patientinfo[14] + "";//职业
            ddlMarriage.SelectedItem = this.Patientinfo[15] + "";//婚姻
            txtPhone.Text = this.Patientinfo[16] + "";//联系电话
            txtInDate.Text = this.Patientinfo[7] + "";//入院时间 改为 入科时间
            if (!string.IsNullOrEmpty(txtInDate.Text))
                txtInDate.Text = Convert.ToDateTime(txtInDate.Text).ToString("yyyy-MM-dd HH:mm");
            if (string.IsNullOrEmpty(txtDiagnose.Text))
                txtDiagnose.Text = this.Patientinfo[17].ToString();//入院诊断
            #endregion

            #region 疼痛 下拉框赋值
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("0", "无痛(0分)");
            dic.Add("1", "安静平卧不痛，翻身咳嗽时疼痛(1分)");
            dic.Add("2", "咳嗽疼痛，深呼吸不痛(2分)");
            dic.Add("3", "安静平卧不痛，咳嗽深呼吸疼痛(3分)");
            dic.Add("4", "安静平卧间隙疼痛(开始影响生活质量)(4分)");
            dic.Add("5", "安静平卧持续疼痛(5分)");
            dic.Add("6", "安静平卧时，疼痛较重(6分)");
            dic.Add("7", "疼痛较重，翻转不安，疲乏、无法入睡(7分)");
            dic.Add("8", "持续疼痛难忍，全身大汗(8分)");
            dic.Add("9", "剧烈疼痛，无法忍受(9分)");
            dic.Add("10", "最疼痛，生不如死(10分)");
            BindingSource bs = new BindingSource();
            bs.DataSource = dic;
            ddlPAIN.DataSource = bs;
            ddlPAIN.ValueMember = "Key";
            ddlPAIN.DisplayMember = "Value";
            #endregion
        }
        public Tb_User InitLoginUser(string[] UserParam)
        {
            UserParm = UserParam;
            LoginUser = new Tb_User();
            LoginUser.UserId = UserParam[0];
            LoginUser.UserName = UserParam[1];
            LoginUser.DepartmentCode = UserParam[2];
            LoginUser.DepartmentName = UserParam[3];
            LoginUser.JobTitle = UserParam[4];
            LoginUser.PositionTitle = UserParam[5];
            return LoginUser;
        }
        /// <summary>
        /// 初始化加载印章图片
        /// </summary>
        private void ElectronicSignature()
        {
            ElectronicSignature es = new ElectronicSignature(LoginUser);
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNURSE, picElectronicSignature, txtNURSE.Location);
        }
        #endregion

        #region 修改、保存
        private void btn_Preservation_Click(object sender, EventArgs e)
        {
            //初始化xml对象
            AssessMent assm = new AssessMent();
            #region 提取数据
            //基本信息
            //姓名
            //patientinfo[2] = txtName.Text;
            assm.JiBenXinXi.XingMing = txtName.Text;
            //性别
            assm.JiBenXinXi.XingBie = ddlSex.Text;
            //年龄
            assm.JiBenXinXi.NianLing = txtAge.Text;
            //病区
            assm.JiBenXinXi.BingQu = txtArea.Text;
            //科室
            assm.JiBenXinXi.KeShi = txtDepartment.Text;
            //床号
            assm.JiBenXinXi.ChuangHao = txtBedNo.Text;
            //病案号
            assm.JiBenXinXi.BingAnHao = txtPatientId.Text;
            //入院时间
            assm.JiBenXinXi.RuYuanShiJian = txtInDate.Text;
            //入院方式
            assm.JiBenXinXi.RuYuanFangShi = ddlMode.Text;
            //体重
            assm.JiBenXinXi.TiZhong = txtWEIGHT.Text;
            //身高
            assm.JiBenXinXi.ShenGao = txtHEIGHT.Text;

            //入院诊断保存 将输入框的诊断存到xml 并判断是否有值 若没有值 则获取源诊断 若有值则同步
            assm.JiBenXinXi.RuYuanZhenDuan = txtDiagnose.Text;
            if (string.IsNullOrEmpty(assm.JiBenXinXi.RuYuanZhenDuan))
            {
                assm.JiBenXinXi.RuYuanZhenDuan = this.Patientinfo[17];
            }
            else
            {
                //同步更新入院诊断到V_YDHL_PATIENT表
                string update_sql = string.Format("UPDATE V_YDHL_PATIENT SET DIAGNOSE='{2}' WHERE PATIENT_ID='{0}' AND VISIT_ID={1}", Patientinfo[0], Patientinfo[1], txtDiagnose.Text);
                int result = SqlHelper.ExecuteNonQuery(Base.ConnStr, CommandType.Text, update_sql, null);
            }

            //名族
            assm.JiBenXinXi.MinZu = ddlNationals.Text;
            //籍贯
            assm.JiBenXinXi.JiGuan = txtNativePlace.Text;
            //文化程度
            assm.JiBenXinXi.WenHuaChengDu = ddlEducation.Text;
            //职业
            assm.JiBenXinXi.ZhiYe = ddlJob.Text;
            //婚姻
            assm.JiBenXinXi.HunYin = ddlMarriage.Text;
            //联系人
            assm.JiBenXinXi.LianXiRen = txtLinkman.Text;
            //与患者关系
            assm.JiBenXinXi.YuHuanZheGuanXi = ddlPATIENT_RELATION.Text;
            //联系电话
            assm.JiBenXinXi.LianXiDianHua = txtPhone.Text;
            //T            
            assm.JiBenXinXi.T = txtTEMPERATURE.Text;
            //P
            assm.JiBenXinXi.P = txtPULSE.Text;
            //R
            assm.JiBenXinXi.R = txtBREATHING.Text;
            //BP
            assm.JiBenXinXi.BP = txtBLOOD_PRESSURE1.Text;
            assm.JiBenXinXi.BPText = txtBLOOD_PRESSURE2.Text;
            //体征信息
            //神志
            string shenzhi = ddlMIND.Text;
            assm.TiZhengXinXi.ShenZhi = shenzhi;
            assm.TiZhengXinXi.ShenZhiText = txtMIND_OTHER.Text;
            if (shenzhi != "其他")
            {
                assm.TiZhengXinXi.ShenZhiText = "";
            }
            //慢病史
            assm.TiZhengXinXi.ManBingShi = (checkEditmanbingshi1.Checked ? "1" : "0") + "#" + (checkEditmanbingshi2.Checked ? "1" : "0") + "#" + (checkEditmanbingshi3.Checked ? "1" : "0") + "#" + (checkEditmanbingshi4.Checked ? "1" : "0") + "#" + (checkEditmanbingshi5.Checked ? "1" : "0");
            assm.TiZhengXinXi.ManBingShiText = txtSLOW_HISTORY_OTHER.Text;
            //手术史
            string oh = ddlOPERATION_HISTORY.Text;
            assm.TiZhengXinXi.ShouShuShi = oh;
            assm.TiZhengXinXi.ShouShuShiText = txtOPERATION_HISTORY_OTHER.Text;
            if (oh == "无")
            {
                assm.TiZhengXinXi.ShouShuShiText = "";
            }
            //视力
            assm.TiZhengXinXi.ShiLi = (checkEditshili1.Checked ? "1" : "0") + "#" + (checkEditshili2.Checked ? "1" : "0") + "#" + (checkEditshili3.Checked ? "1" : "0") + "#" + (checkEditshili4.Checked ? "1" : "0") + "#" + (checkEditshili5.Checked ? "1" : "0") + "#" + (checkEditshili6.Checked ? "1" : "0") + "#" + (checkEditshili7.Checked ? "1" : "0") + "#" + (checkEditshili8.Checked ? "1" : "0");
            assm.TiZhengXinXi.ShiLiText = txtVISION_OTHER.Text;
            //听力
            assm.TiZhengXinXi.TingLi = (checkEdittingli1.Checked ? "1" : "0") + "#" + (checkEdittingli2.Checked ? "1" : "0") + "#" + (checkEdittingli3.Checked ? "1" : "0") + "#" + (checkEdittingli4.Checked ? "1" : "0") + "#" + (checkEdittingli5.Checked ? "1" : "0") + "#" + (checkEdittingli6.Checked ? "1" : "0") + "#" + (checkEdittingli7.Checked ? "1" : "0");
            assm.TiZhengXinXi.TingLiText = txtHEARING_OTHER.Text;
            //皮肤
            assm.TiZhengXinXi.PiFu = ddlSKIN.Text;
            assm.TiZhengXinXi.PiFuText = txtSKIN_OTHER.Text;
            //过敏史
            assm.TiZhengXinXi.GuoMinShi = (chkALLERGY_HISTORY.Checked ? "1" : "0") + "#" + (chkALLERGY_HISTORY_MEDICINE.Checked ? "1" : "0") + "#" + (chkALLERGY_HISTORY_FOOD.Checked ? "1" : "0") + "#" + (chkALLERGY_HISTORY_OTHER.Checked ? "1" : "0");
            if (!chkALLERGY_HISTORY_MEDICINE.Checked)
            {
                assm.TiZhengXinXi.GuoMinShiYaoWu = "";
            }
            else
            {
                assm.TiZhengXinXi.GuoMinShiYaoWu = ddlALLERGY_HISTORY_MEDICINE.Text;
            }
            if (!chkALLERGY_HISTORY_FOOD.Checked)
            {
                assm.TiZhengXinXi.GuoMinShiShiWu = "";
            }
            else
            {
                assm.TiZhengXinXi.GuoMinShiShiWu = ddlALLERGY_HISTORY_FOOD.Text;
            }
            assm.TiZhengXinXi.GuoMinShiQiTa = txtALLERGY_HISTORY_OTHER.Text;
            //食欲
            assm.SheHuiPingGu.ShiYu = ddlDIET_APPETITE.Text;
            //方式
            assm.SheHuiPingGu.FangShi = ddlDIET_MOTHOD.Text;
            //活动
            assm.SheHuiPingGu.HuoDong = (checkEdithuodong1.Checked ? "1" : "0") + "#" + (checkEdithuodong2.Checked ? "1" : "0") + "#" + (checkEdithuodong3.Checked ? "1" : "0") + "#" + (checkEdithuodong4.Checked ? "1" : "0") + "#" + (checkEdithuodong5.Checked ? "1" : "0") + "#" + (checkEdithuodong6.Checked ? "1" : "0") + "#" + (checkEdithuodong7.Checked ? "1" : "0");
            //活动其他
            assm.SheHuiPingGu.HuoDongText = comboBoxEdithuodongqita.Text;
            //睡眠
            assm.SheHuiPingGu.ShuiMian = ddlSLEEP.Text;
            //排便
            assm.SheHuiPingGu.PaiBian = ddlDEFECATION.Text;
            //排尿
            assm.SheHuiPingGu.PaiNiao = ddlMICTURITION.Text;
            //吸烟
            assm.SheHuiPingGu.XiYan = ddlSMOKE.Text;
            assm.SheHuiPingGu.XiYanZhi = txtSMOKING_COUNTS_PER_DAY.Text;
            assm.SheHuiPingGu.XiYanNian = txtSMOKE_YEAR.Text;
            //饮酒
            assm.SheHuiPingGu.YinJiu = ddlDRINK.Text;
            assm.SheHuiPingGu.YinJiuMl = txtDRINK_ML.Text;
            assm.SheHuiPingGu.YinJiuNian = txtDRINK_YEAR.Text;
            //疼痛
            //宗教信仰
            assm.DieDaoYaChuangADLFengXianPingGu.DieDaoPingGuFenShu = txtFALL_RISK_ASSESSMENT_SCORE.Text;
            assm.DieDaoYaChuangADLFengXianPingGu.DieDaoPingGu = (chkFALL_RISK_ASSESSMENT_ITEM1.Checked ? "1" : "0") + "#" + (chkFALL_RISK_ASSESSMENT_ITEM2.Checked ? "1" : "0");
            //压疮风险评估
            assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGuFenShu = txtPRESSURE_RISK_ASSESSMENT_SCORE.Text;
            assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGu = (chkPRESSURE_RISK_ASSESSMENT_ITEM1.Checked ? "1" : "0") + "#" + (chkPRESSURE_RISK_ASSESSMENT_ITEM2.Checked ? "1" : "0") + "#" + (chkPRESSURE_RISK_ASSESSMENT_ITEM3.Checked ? "1" : "0") + "#" + (chkPRESSURE_RISK_ASSESSMENT_ITEM4.Checked ? "1" : "0") + "#" + (chkPRESSURE_RISK_ASSESSMENT_ITEM5.Checked ? "1" : "0");
            //ADL
            assm.DieDaoYaChuangADLFengXianPingGu.ADLPingGuFenShu = txtADL_SCORE.Text;
            assm.DieDaoYaChuangADLFengXianPingGu.ADLPingGu = (chkADL_SCORE_ITEM1.Checked ? "1" : "0") + "#" + (chkADL_SCORE_ITEM2.Checked ? "1" : "0") + "#" + (chkADL_SCORE_ITEM3.Checked ? "1" : "0") + "#" + (chkADL_SCORE_ITEM4.Checked ? "1" : "0");
            //出院日期
            assm.ChuYuanPingGu.ChuYuanRiQi = txtOUT_DATE.Text;
            //出院诊断
            assm.ChuYuanPingGu.ChuYuanZhenDuan = txtDISCHARGE_DIAGNOSIS.Text;
            //自理能力
            assm.ChuYuanPingGu.ZiLiNengLi = (chkADL_SCORE_ITEM_OUT1.Checked ? "1" : "0") + "#" + (chkADL_SCORE_ITEM_OUT2.Checked ? "1" : "0") + "#" + (chkADL_SCORE_ITEM_OUT3.Checked ? "1" : "0") + "#" + (chkADL_SCORE_ITEM_OUT4.Checked ? "1" : "0");
            assm.ChuYuanPingGu.ADLPingFen = txtADL_SCORE_OUT.Text;
            //出院后去向
            assm.ChuYuanPingGu.ChuYuanHouQuXiang = (chkWHERE_AFTER_DISCHARGE1.Checked ? "1" : "0") + "#" + (chkWHERE_AFTER_DISCHARGE2.Checked ? "1" : "0") + "#" + (chkWHERE_AFTER_DISCHARGE3.Checked ? "1" : "0") + "#" + (chkWHERE_AFTER_DISCHARGE4.Checked ? "1" : "0") + "#" + (chkWHERE_AFTER_DISCHARGE5.Checked ? "1" : "0");
            //入院护士签名      
            assm.DieDaoYaChuangADLFengXianPingGu.RuYuanHuShiQianMing = txtNURSE1.Text;
            if (txtNURSE1Id && !string.IsNullOrEmpty(txtNURSE1.Text) && txtNURSE1.Text.Equals(this.UserParm[1]))
                assm.DieDaoYaChuangADLFengXianPingGu.RuYuanHuShiQianMing_ID = this.UserParm[0];

            //出院护士签名      
            assm.ChuYuanPingGu.ChuYuanHuShiQianMing = txtNURSE.Text;
            if (txtNURSEId && !string.IsNullOrEmpty(txtNURSE.Text) && txtNURSE.Text.Equals(this.UserParm[1]))
                assm.ChuYuanPingGu.ChuYuanHuShiQianMing_ID = this.UserParm[0];

            //表单ID
            assm.FormId = (int)FormType.ZYHZHLPGD;
            //表单名字
            assm.SheHuiPingGu.ZongJiaoXinYang = ddlRELIGIOUS_BELIEF.Text;
            assm.SheHuiPingGu.TengTong = ddlPAIN.SelectedValue + "";
            //心里
            assm.SheHuiPingGu.XinLi = ddlIN_MIND.Text;
            assm.SheHuiPingGu.XinLiText = txtIN_MIND_OTHER.Text;
            //居住情况
            assm.SheHuiPingGu.JuZhuZhuangKuang = (chkLIVING_CONDITION1.Checked ? "1" : "0") + "#" + (chkLIVING_CONDITION2.Checked ? "1" : "0") + "#" + (chkLIVING_CONDITION3.Checked ? "1" : "0") + "#" + (chkLIVING_CONDITION4.Checked ? "1" : "0") + "#" + (chkLIVING_CONDITION5.Checked ? "1" : "0") + "#" + (chkLIVING_CONDITION6.Checked ? "1" : "0");
            assm.SheHuiPingGu.JuZhuZhuangKuangText = txtLIVING_CONDITION_OTHER.Text;
            assm.SheHuiPingGu.ZongJiaoXinYangText = txtRELIGIOUS_BELIEF_OTHER.Text;
            //费用来源
            assm.SheHuiPingGu.FeiYongLaiYuan = (checkEditfeiyonglaiyuan1.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan2.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan3.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan4.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan5.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan6.Checked ? "1" : "0");
            assm.SheHuiPingGu.FeiYongLaiYuanText = txtCOST_SOURCES_OTHER.Text;
            //特殊人群
            assm.SheHuiPingGu.TeShuRenQun = (chkSPECIAL_GROUP1.Checked ? "1" : "0") + "#" + (chkSPECIAL_GROUP2.Checked ? "1" : "0") + "#" + (chkSPECIAL_GROUP3.Checked ? "1" : "0") + "#" + (chkSPECIAL_GROUP4.Checked ? "1" : "0") + "#" + (chkSPECIAL_GROUP5.Checked ? "1" : "0") + "#" + (chkSPECIAL_GROUP6.Checked ? "1" : "0") + "#" + (chkSPECIAL_GROUP7.Checked ? "1" : "0") + "#" + (chkSPECIAL_GROUP8.Checked ? "1" : "0");
            //跌到风险评估
            assm.FormName = EnumHelper.GetDescription(FormType.ZYHZHLPGD);
            #endregion
            var ret = formService.GetNursingFormRecord(Patientinfo[0], Convert.ToInt32(Patientinfo[1]), (int)FormType.ZYHZHLPGD);
            if (ret.D != null)
            {
                var NursingFormRecord = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NursingFormRecord>>(ret.D);
                record.Id = NursingFormRecord[0].Id;
            }
            //住院号
            record.PatientId = Patientinfo[0];
            //住院次数
            record.VisitId = Convert.ToInt32(Patientinfo[1]);
            //患者姓名
            record.PatientName = Patientinfo[2];
            //床号
            record.BedNo = Patientinfo[5];
            //当前患者科室ID
            record.DepartmentId = Patientinfo[8];
            //当前患者科室名称
            record.DepartmentName = Patientinfo[9];
            //当前患者病区ID
            record.AreaId = Patientinfo[10];
            //当前患者病区名称
            record.AreaName = Patientinfo[11];
            //表单ID
            record.FormId = (int)FormType.ZYHZHLPGD;
            //表单名字
            record.FormName = EnumHelper.GetDescription(FormType.ZYHZHLPGD);
            record.NursingFormData = XmlUtil.ObjectToXML(assm, Encoding.UTF8);
            var ret2 = formService.SetNursingFormRecord(Newtonsoft.Json.JsonConvert.SerializeObject(record));

            if (ret2.S == true)
            {
                //电签开始
                if (Base.ESSwitch.Equals("on"))
                {
                    string signXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><xingming name=\"姓名\">" + txtName.Text + "</xingming><xingbie Name=\"性别\">" + ddlSex.Text + "</xingbie>"
                        + "<nianling Name=\"年龄\">" + txtAge.Text + "</nianling><bingqu Name=\"病区\">" + txtArea.Text + "</bingqu><keshi Name=\"科室\">" + txtDepartment.Text + "</keshi>"
                        + "<chuanghao Name=\"床号\">" + txtBedNo.Text + "</chuanghao><binganhao Name=\"病案号\">" + txtPatientId.Text + "</binganhao><ruyuanshijian Name=\"入院时间\">" + txtInDate.Text + "</ruyuanshijian>"
                        + "<ruyuanfangshi Name=\"入院方式\">" + ddlMode.Text + "</ruyuanfangshi><tizhong Name=\"体重\">" + txtWEIGHT.Text + "</tizhong><shengao Name=\"身高\">" + txtHEIGHT.Text + "</shengao>"
                        + "<ruyuanzhenduan Name=\"入院诊断\">" + txtDiagnose.Text + "</ruyuanzhenduan><mingzu Name=\"名族\">" + ddlNationals.Text + "</mingzu><jiguan Name=\"籍贯\">" + txtNativePlace.Text + "</jiguan>"
                        + "<wenhuachengdu Name=\"文化程度\">" + ddlEducation.Text + "</wenhuachengdu><zhiye Name=\"职业\">" + ddlJob.Text + "</zhiye><hunyin Name=\"婚姻\">" + ddlMarriage.Text + "</hunyin>"
                        + "<lianxiren Name=\"联系人\">" + txtLinkman.Text + "</lianxiren><yuhuanzheguanxi Name=\"与患者关系\">" + ddlPATIENT_RELATION.Text + "</yuhuanzheguanxi><lainxidianhua Name=\"联系电话\">" + txtPhone.Text + "</lainxidianhua>"
                        + "<tiwen Name=\"T\">" + txtTEMPERATURE.Text + "</tiwen><p Name=\"P\">" + txtPULSE.Text + "</p><r Name=\"R\">" + txtBREATHING.Text + "</r><bp Name=\"BP\">" + txtBLOOD_PRESSURE1.Text + "</bp>"
                        + "<bp Name=\"BP\">" + txtBLOOD_PRESSURE2.Text + "</bp><shenzhi Name=\"神志\">" + ddlMIND.Text + "</shenzhi><shenzhi Name=\"神志\">" + txtMIND_OTHER.Text + "</shenzhi><manbingshi Name=\"慢病史\">" + txtMIND_OTHER.Text + "</manbingshi><manbingshi Name=\"慢病史\">" + txtSLOW_HISTORY_OTHER.Text + "</manbingshi>"
                        + "<shoushushi Name=\"手术史\">" + ddlOPERATION_HISTORY.Text + "</shoushushi><shoushushi Name=\"手术史\">" + txtOPERATION_HISTORY_OTHER.Text + "</shoushushi><shili Name=\"视力\">" + (checkEditshili1.Checked ? "1" : "0") + "#" + (checkEditshili2.Checked ? "1" : "0") + "#" + (checkEditshili3.Checked ? "1" : "0") + "#" + (checkEditshili4.Checked ? "1" : "0") + "#" + (checkEditshili5.Checked ? "1" : "0") + "#" + (checkEditshili6.Checked ? "1" : "0") + "#" + (checkEditshili7.Checked ? "1" : "0") + "#" + (checkEditshili8.Checked ? "1" : "0") + "</shili><shili Name=\"视力\">" + txtVISION_OTHER.Text + "</shili>"
                        + "<tingli Name=\"听力\">" + (checkEdittingli1.Checked ? "1" : "0") + "#" + (checkEdittingli2.Checked ? "1" : "0") + "#" + (checkEdittingli3.Checked ? "1" : "0") + "#" + (checkEdittingli4.Checked ? "1" : "0") + "#" + (checkEdittingli5.Checked ? "1" : "0") + "#" + (checkEdittingli6.Checked ? "1" : "0") + "#" + (checkEdittingli7.Checked ? "1" : "0") + "</tingli><tingli Name=\"听力\">" + txtHEARING_OTHER.Text + "</tingli><pifu Name=\"皮肤\">" + ddlSKIN.Text + "</pifu><pifu Name=\"皮肤\">" + txtSKIN_OTHER.Text + "</pifu>"
                        + "<guominshi Name=\"过敏史\">" + chkALLERGY_HISTORY.Text + "</guominshi><guominshi Name=\"过敏史\">" + chkALLERGY_HISTORY_MEDICINE.Text + "</guominshi><guominshi Name=\"过敏史\">" + ddlALLERGY_HISTORY_MEDICINE.Text + "</guominshi>"
                        + "<guominshi Name=\"过敏史\">" + chkALLERGY_HISTORY_FOOD.Text + "</guominshi><guominshi Name=\"过敏史\">" + ddlALLERGY_HISTORY_FOOD.Text + "</guominshi><guominshi Name=\"过敏史\">" + chkALLERGY_HISTORY_OTHER.Text + "</guominshi>"
                        + "<guominshi Name=\"过敏史\">" + txtALLERGY_HISTORY_OTHER.Text + "</guominshi><shiyu Name=\"食欲\">" + ddlDIET_APPETITE.Text + "</shiyu><fansghi Name=\"方式\">" + ddlDIET_MOTHOD.Text + "</fansghi>"
                        + "<huodong Name=\"活动\">" + (checkEdithuodong1.Checked ? "1" : "0") + "#" + (checkEdithuodong2.Checked ? "1" : "0") + "#" + (checkEdithuodong3.Checked ? "1" : "0") + "#" + (checkEdithuodong4.Checked ? "1" : "0") + "#" + (checkEdithuodong5.Checked ? "1" : "0") + "#" + (checkEdithuodong6.Checked ? "1" : "0") + "#" + (checkEdithuodong7.Checked ? "1" : "0") + "</huodong><shuimian Name=\"睡眠\">" + ddlSLEEP.Text + "</shuimian><paibian Name=\"排便\">" + ddlDEFECATION.Text + "</paibian><painiao Name=\"排尿\">" + ddlMICTURITION.Text + "</painiao>"
                        + "<xiyan Name=\"吸烟\">" + ddlSMOKE.Text + "</xiyan><xiyan Name=\"吸烟\">" + txtSMOKING_COUNTS_PER_DAY.Text + "</xiyan><xiyan Name=\"吸烟\">" + txtSMOKE_YEAR.Text + "</xiyan><yinjiu Name=\"饮酒\">" + ddlDRINK.Text + "</yinjiu><yinjiu Name=\"饮酒\">" + txtDRINK_ML.Text + "</yinjiu><yinjiu Name=\"饮酒\">" + txtDRINK_YEAR.Text + "</yinjiu>"
                        + "<tengtong Name=\"疼痛\">" + ddlPAIN.Text + "</tengtong><xinli Name=\"心理\">" + ddlIN_MIND.Text + "</xinli><xinli Name=\"心理\">" + txtIN_MIND_OTHER.Text + "</xinli><juzhuqingkuang Name=\"居住情况\">" + chkLIVING_CONDITION1.Text + "</juzhuqingkuang><juzhuqingkuang Name=\"居住情况\">" + chkLIVING_CONDITION2.Text + "</juzhuqingkuang>"
                        + "<juzhuqingkuang Name=\"居住情况\">" + chkLIVING_CONDITION3.Text + "</juzhuqingkuang><juzhuqingkuang Name=\"居住情况\">" + chkLIVING_CONDITION4.Text + "</juzhuqingkuang><juzhuqingkuang Name=\"居住情况\">" + chkLIVING_CONDITION5.Text + "</juzhuqingkuang><juzhuqingkuang Name=\"居住情况\">" + chkLIVING_CONDITION6.Text + "</juzhuqingkuang>"
                        + "<juzhuqingkuang Name=\"居住情况\">" + txtLIVING_CONDITION_OTHER.Text + "</juzhuqingkuang><zongjiaoxinyang Name=\"宗教信仰\">" + ddlRELIGIOUS_BELIEF.Text + "</zongjiaoxinyang><zongjiaoxinyang Name=\"宗教信仰\">" + txtRELIGIOUS_BELIEF_OTHER.Text + "</zongjiaoxinyang>"
                        + "<feiyonglaiyuan Name=\"费用来源\">" + (checkEditfeiyonglaiyuan1.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan2.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan3.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan4.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan5.Checked ? "1" : "0") + "#" + (checkEditfeiyonglaiyuan6.Checked ? "1" : "0") + "</feiyonglaiyuan><feiyonglaiyuan Name=\"费用来源\">" + txtCOST_SOURCES_OTHER.Text + "</feiyonglaiyuan><teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP1.Text + "</teshurenqun><teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP2.Text + "</teshurenqun>"
                        + "<teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP3.Text + "</teshurenqun><teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP4.Text + "</teshurenqun><teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP5.Text + "</teshurenqun><teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP6.Text + "</teshurenqun><teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP7.Text + "</teshurenqun>"
                        + "<teshurenqun Name=\"特殊人群\">" + chkSPECIAL_GROUP8.Text + "</teshurenqun>"
                        + "<diandaofengxianpinggu Name=\"跌倒风险评估\">" + txtFALL_RISK_ASSESSMENT_SCORE.Text + "</diandaofengxianpinggu><diandaofengxianpinggu Name=\"跌倒风险评估\">" + chkFALL_RISK_ASSESSMENT_ITEM1.Text + "</diandaofengxianpinggu><diandaofengxianpinggu Name=\"跌倒风险评估\">" + chkFALL_RISK_ASSESSMENT_ITEM2.Text + "</diandaofengxianpinggu>"
                        + "<yachuanfengxianpinggu Name=\"压疮风险评估\">" + txtPRESSURE_RISK_ASSESSMENT_SCORE.Text + "</yachuanfengxianpinggu><yachuanfengxianpinggu Name=\"压疮风险评估\">" + chkPRESSURE_RISK_ASSESSMENT_ITEM1.Text + "</yachuanfengxianpinggu><yachuanfengxianpinggu Name=\"压疮风险评估\">" + chkPRESSURE_RISK_ASSESSMENT_ITEM2.Text + "</yachuanfengxianpinggu>"
                        + "<yachuanfengxianpinggu Name=\"压疮风险评估\">" + chkPRESSURE_RISK_ASSESSMENT_ITEM3.Text + "</yachuanfengxianpinggu><yachuanfengxianpinggu Name=\"压疮风险评估\">" + chkPRESSURE_RISK_ASSESSMENT_ITEM4.Text + "</yachuanfengxianpinggu><yachuanfengxianpinggu Name=\"压疮风险评估\">" + chkPRESSURE_RISK_ASSESSMENT_ITEM5.Text + "</yachuanfengxianpinggu>"
                        + "<adlpingfen Name=\"ADL评分\">" + txtADL_SCORE.Text + "</adl><adlpingfen Name=\"ADL评分\">" + chkADL_SCORE_ITEM1.Text + "</adl><adlpingfen Name=\"ADL评分\">" + chkADL_SCORE_ITEM2.Text + "</adl><adlpingfen Name=\"ADL评分\">" + chkADL_SCORE_ITEM3.Text + "</adl><adlpingfen Name=\"ADL评分\">" + chkADL_SCORE_ITEM4.Text + "</adl>"
                        + "<chuyuanriqi Name=\"出院日期\">" + txtOUT_DATE.Text + "</chuyuanriqi><chuyuanzhenduan Name=\"出院诊断\">" + txtDISCHARGE_DIAGNOSIS.Text + "</chuyuanzhenduan><zilinengli Name=\"自理能力\">" + txtADL_SCORE_OUT.Text + "</zilinengli><zilinengli Name=\"自理能力\">" + chkADL_SCORE_ITEM_OUT1.Text + "</zilinengli><zilinengli Name=\"自理能力\">" + chkADL_SCORE_ITEM_OUT2.Text + "</zilinengli>"
                        + "<zilinengli Name=\"自理能力\">" + chkADL_SCORE_ITEM_OUT3.Text + "</zilinengli><zilinengli Name=\"自理能力\">" + chkADL_SCORE_ITEM_OUT4.Text + "</zilinengli><chuyuanhouquxiang Name=\"出院后去向\">" + chkWHERE_AFTER_DISCHARGE1.Text + "</chuyuanhouquxiang><chuyuanhouquxiang Name=\"出院后去向\">" + chkWHERE_AFTER_DISCHARGE2.Text + "</chuyuanhouquxiang>"
                        + "<chuyuanhouquxiang Name=\"出院后去向\">" + chkWHERE_AFTER_DISCHARGE3.Text + "</chuyuanhouquxiang><chuyuanhouquxiang Name=\"出院后去向\">" + chkWHERE_AFTER_DISCHARGE4.Text + "</chuyuanhouquxiang><chuyuanhouquxiang Name=\"出院后去向\">" + chkWHERE_AFTER_DISCHARGE5.Text + "</chuyuanhouquxiang><ruyuanhushiqianming Name=\"护士签名\">" + txtNURSE1.Text + "</hushiqianming><chuyuanhushiqianming Name=\"护士签名\">" + txtNURSE.Text + "</hushiqianming>";
                    //TODO:电签接口提交
                    string extraInfo = "<?xml version=\"1.0\" encoding=\"UTF-16\"?><root><sign_sys>{0}</sign_sys><title>{1}</title><patient_id>{2}</patient_id><patient_name>{3}</patient_name><emr_id>{4}</emr_id><emr_catalog>{5}</emr_catalog><his_id>{6}</his_id><event_no>{7}</event_no><visit_number>{8}</visit_number><dept_name>{9}</dept_name><prescribe_number>{10}</prescribe_number><prescribe_sub_number>{11}</prescribe_sub_number><prescribe_operation>医嘱操作（发送、校对、停止、作废）或门诊处方操作（发送）</prescribe_operation><radiotherapy_id>放疗号</radiotherapy_id><process_name>CT定位申请单审核</process_name><process_time>CT定位申请单审核时间</process_time><extend_value_1>备用扩展1</extend_value_1><extend_value_2>备用扩展2</extend_value_2><extend_value_3>备用扩展3</extend_value_3><extend_value_4>备用扩展4</extend_value_4><extend_value_5>备用扩展5</extend_value_5><extend_value_6>备用扩展6</extend_value_6><extend_value_7>备用扩展7</extend_value_7><extend_value_8>备用扩展8</extend_value_8><extend_value_9>备用扩展9</extend_value_9></root>";
                    extraInfo = string.Format(extraInfo, record.FormName + "-更新", record.FormName, record.PatientId, record.PatientName, record.Id, record.FormId, "", record.PatientId, record.VisitId, LoginUser.DepartmentName, record.PatientId, record.PatientId);
                    ElectronicSignature es = new ElectronicSignature(LoginUser);
                    bool res = es.GetElectronicSignatureImage(es, signXml, extraInfo, record.FormId.ToString(), record.FormName, Patientinfo[0], int.Parse(Patientinfo[1]));
                    if (!res) { MessageBox.Show("电子签名失败"); return; }
                }
                //电签结束
                if (((DevExpress.XtraEditors.SimpleButton)(sender)).Text == "保存")
                {
                    MessageBox.Show(ret2.M);
                }
            }
            else
            {
                if (((DevExpress.XtraEditors.SimpleButton)(sender)).Text == "保存")
                {
                    MessageBox.Show(ret2.M);
                }
            }
        }
        #endregion

        #region 打印
        private void btn_Printing_Click(object sender, EventArgs e)
        {
            btn_Preservation_Click(sender, e);
            NursingFormPrint nfp = new NursingFormPrint(Patientinfo, (int)FormType.ZYHZHLPGD, UserParm);
            nfp.Show();
        }
        #endregion

        #region 其他选项,勾选时显示文本框，不勾选时，隐藏文本框

        private void checkEditmanbingshi5_CheckedChanged(object sender, EventArgs e)
        {
            txtSLOW_HISTORY_OTHER.Visible = false;
            if (checkEditmanbingshi5.Checked)    //慢病史-其他
            {
                txtSLOW_HISTORY_OTHER.Visible = true;
            }
            else
            {
                txtSLOW_HISTORY_OTHER.Text = "";
            }
        }

        private void checkEditshili8_CheckedChanged(object sender, EventArgs e)
        {
            txtVISION_OTHER.Visible = false;
            if (checkEditshili8.Checked)    //视力-其他
            {
                txtVISION_OTHER.Visible = true;
            }
            else
            {
                txtVISION_OTHER.Text = "";
            }
        }

        private void checkEdittingli7_CheckedChanged(object sender, EventArgs e)
        {
            txtHEARING_OTHER.Visible = false;
            if (checkEdittingli7.Checked)    //听力-其他
            {
                txtHEARING_OTHER.Visible = true;
            }
            else
            {
                txtHEARING_OTHER.Text = "";
            }
        }

        private void checkEditfeiyonglaiyuan6_CheckedChanged(object sender, EventArgs e)
        {
            txtCOST_SOURCES_OTHER.Visible = false;
            if (checkEditfeiyonglaiyuan6.Checked)   //费用来源-其他
            {
                txtCOST_SOURCES_OTHER.Visible = true;
            }
            else
            {
                txtCOST_SOURCES_OTHER.Text = "";
            }
        }

        private void chbALLERGY_HISTORY_MEDICINE_CheckedChanged(object sender, EventArgs e)
        {
            ddlALLERGY_HISTORY_MEDICINE.Visible = false;
            if (chkALLERGY_HISTORY_MEDICINE.Checked)    //过敏史选中药物
            {
                ddlALLERGY_HISTORY_MEDICINE.Visible = true;
            }
            else
            {
                ddlALLERGY_HISTORY_MEDICINE.Text = "";
            }
        }

        private void chbALLERGY_HISTORY_FOOD_CheckedChanged(object sender, EventArgs e)
        {
            ddlALLERGY_HISTORY_FOOD.Visible = false;
            if (chkALLERGY_HISTORY_FOOD.Checked)   //过敏史选中食物
            {
                ddlALLERGY_HISTORY_FOOD.Visible = true;
            }
            else
            {
                ddlALLERGY_HISTORY_FOOD.Text = "";
            }

        }

        private void chbALLERGY_HISTORY_OTHER_CheckedChanged(object sender, EventArgs e)
        {
            txtALLERGY_HISTORY_OTHER.Visible = false;
            if (chkALLERGY_HISTORY_OTHER.Checked)    //过敏史选中其他
            {
                txtALLERGY_HISTORY_OTHER.Visible = true;
            }
            else
            {
                txtALLERGY_HISTORY_OTHER.Text = "";
            }
        }

        private void chkLIVING_CONDITION6_Checked(object sender, EventArgs e)
        {
            txtLIVING_CONDITION_OTHER.Visible = false;
            if (chkLIVING_CONDITION6.Checked)   //居住状况
            {
                txtLIVING_CONDITION_OTHER.Visible = true;
            }
            else
            {
                txtLIVING_CONDITION_OTHER.Text = "";
            }
        }


        private void ddlMIND_SelectedValueChanged(object sender, EventArgs e)
        {
            txtMIND_OTHER.Visible = false;
            if (ddlMIND.SelectedItem + "" == "其他")    //神志
            {
                txtMIND_OTHER.Visible = true;
            }
            else
            {
                txtMIND_OTHER.Text = "";
            }
        }

        private void ddlOPERATION_HISTORY_SelectedValueChanged(object sender, EventArgs e)
        {
            txtOPERATION_HISTORY_OTHER.Visible = false;
            if (ddlOPERATION_HISTORY.SelectedItem + "" == "有")   //手术史
            {
                txtOPERATION_HISTORY_OTHER.Visible = true;
            }
            else
            {
                txtOPERATION_HISTORY_OTHER.Text = "";
            }
        }


        private void ddlSMOKE_SelectedValueChanged(object sender, EventArgs e)
        {
            txtSMOKING_COUNTS_PER_DAY.Visible = false;
            txtSMOKE_YEAR.Visible = false;
            if (ddlSMOKE.SelectedItem + "" == "有")     //有吸烟
            {
                txtSMOKING_COUNTS_PER_DAY.Visible = true;
                txtSMOKE_YEAR.Visible = true;
            }
            else
            {
                txtSMOKING_COUNTS_PER_DAY.Text = "";
                txtSMOKE_YEAR.Text = "";
            }
        }

        private void ddlDRINK_SelectedValueChanged(object sender, EventArgs e)
        {
            if (ddlDRINK.SelectedItem + "" == "经常饮酒")//有喝酒
            {
                txtDRINK_ML.Visible = true;
                txtDRINK_YEAR.Visible = true;
            }
            else
            {
                txtDRINK_ML.Visible = false;
                txtDRINK_YEAR.Visible = false;
                txtDRINK_ML.Text = "";
                txtDRINK_YEAR.Text = "";
            }
        }

        private void ddlRELIGIOUS_BELIEF_SelectedValueChanged(object sender, EventArgs e)
        {
            txtRELIGIOUS_BELIEF_OTHER.Visible = false;
            if (ddlRELIGIOUS_BELIEF.SelectedItem + "" == "其他")    //宗教信仰
            {
                txtRELIGIOUS_BELIEF_OTHER.Visible = true;
            }
            else
            {
                txtRELIGIOUS_BELIEF_OTHER.Text = "";
            }
        }

        private void ddlSKIN_SelectedValueChanged(object sender, EventArgs e)
        {
            txtSKIN_OTHER.Visible = false;
            if (ddlSKIN.SelectedItem + "" == "其他")    //皮肤
            {
                txtSKIN_OTHER.Visible = true;
            }
            else
            {
                txtSKIN_OTHER.Text = "";
            }
        }

        private void ddlIN_MIND_SelectedValueChanged(object sender, EventArgs e)
        {
            txtIN_MIND_OTHER.Visible = false;
            if (ddlIN_MIND.SelectedItem + "" == "其他")     //心理
            {
                txtIN_MIND_OTHER.Visible = true;
            }
            else
            {
                txtIN_MIND_OTHER.Text = "";
            }
        }

        private void checkEdithuodong7_CheckedChanged(object sender, EventArgs e)
        {
            comboBoxEdithuodongqita.Visible = false;
            if (checkEdithuodong7.Checked)     //心理
            {
                comboBoxEdithuodongqita.Visible = true;
            }
            else
            {
                comboBoxEdithuodongqita.Text = "";
            }
        }
        #endregion

        #region 置空
        private void setNull()
        {
            txtName.Text = "";//姓名
            ddlSex.Text = "";//性别
            txtAge.Text = "";//年龄
            txtBedNo.Text = "";//床号
            txtArea.Text = "";//病区
            txtDepartment.Text = "";//科室
            txtPatientId.Text = "";//病案号
            ddlNationals.Text = "";//民族
            txtNativePlace.Text = "";//籍贯
            ddlEducation.Text = "";//文化程度
            ddlJob.Text = "";//职业
            ddlMarriage.Text = "";//婚姻
            txtLinkman.Text = "";//联系人
            ddlPATIENT_RELATION.Text = "";//与患者关系
            txtPhone.Text = "";//联系电话
            txtInDate.Text = "";//入院时间
            ddlMode.Text = "";//入院方式
            txtDiagnose.Text = ""; //入院诊断
            ddlMIND.Text = "";//神志
            txtMIND_OTHER.Text = "";
            //txtMIND_OTHER.Enabled = false;
            checkEditmanbingshi1.Checked = false; //慢病史-无
            checkEditmanbingshi2.Checked = false; //慢病史-高血压
            checkEditmanbingshi3.Checked = false; //慢病史-冠心病
            checkEditmanbingshi4.Checked = false; //慢病史-糖尿病
            checkEditmanbingshi5.Checked = false; //慢病史-其他
            txtSLOW_HISTORY_OTHER.Text = "";      //慢病史-其他-文本框
            //txtSLOW_HISTORY_OTHER.Enabled = false;
            ddlOPERATION_HISTORY.Text = "";//手术史
            txtOPERATION_HISTORY_OTHER.Text = "";
            //txtOPERATION_HISTORY_OTHER.Enabled = false;
            chkALLERGY_HISTORY.Checked = false;//过敏史：未发现
            chkALLERGY_HISTORY_MEDICINE.Checked = false;//过敏史：药物
            ddlALLERGY_HISTORY_MEDICINE.Text = "";
            //ddlALLERGY_HISTORY_MEDICINE.Enabled = false;
            chkALLERGY_HISTORY_FOOD.Checked = false;//过敏史：食物
            ddlALLERGY_HISTORY_FOOD.Text = "";
            //ddlALLERGY_HISTORY_FOOD.Enabled = false;
            chkALLERGY_HISTORY_OTHER.Checked = false;//过敏史：其他
            txtALLERGY_HISTORY_OTHER.Text = "";
            //txtALLERGY_HISTORY_OTHER.Enabled = false;
            checkEditshili1.Checked = false; //视力-正常
            checkEditshili2.Checked = false; //视力-弱视
            checkEditshili3.Checked = false; //视力-近视
            checkEditshili4.Checked = false; //视力-远视
            checkEditshili5.Checked = false; //视力-失明左
            checkEditshili6.Checked = false; //视力-失明右
            checkEditshili7.Checked = false; //视力-无法判断
            checkEditshili8.Checked = false; //视力-其他
            txtVISION_OTHER.Text = ""; //视力-其他-文本框
            //txtVISION_OTHER.Enabled = false;
            checkEdittingli1.Checked = false; //听力-正常
            checkEdittingli2.Checked = false; //听力-弱听
            checkEdittingli3.Checked = false; //听力-助听
            checkEdittingli4.Checked = false; //听力-失聪左
            checkEdittingli5.Checked = false; //听力-失聪右
            checkEdittingli6.Checked = false; //听力-无法判断
            checkEdittingli7.Checked = false; //听力-其他
            txtHEARING_OTHER.Text = ""; //听力-其他-文本框
            //txtHEARING_OTHER.Enabled = false;
            ddlSKIN.Text = "";//皮肤
            txtSKIN_OTHER.Text = "";
            //txtSKIN_OTHER.Enabled = false;
            ddlDIET_APPETITE.Text = "";//饮食食欲
            ddlDIET_MOTHOD.Text = "";//饮食方式
            checkEdithuodong1.Checked = false; //活动-自如
            checkEdithuodong2.Checked = false; //活动-障碍
            checkEdithuodong3.Checked = false; //活动-肢体瘫痪左上
            checkEdithuodong4.Checked = false; //活动-肢体瘫痪左下
            checkEdithuodong5.Checked = false; //活动-肢体瘫痪右上
            checkEdithuodong6.Checked = false; //活动-肢体瘫痪右下
            checkEdithuodong7.Checked = false; //活动-其他
            ddlSLEEP.Text = "";//睡眠
            ddlDEFECATION.Text = "";//排便
            ddlMICTURITION.Text = "";//排尿
            ddlSMOKE.Text = "";//吸烟
            txtSMOKING_COUNTS_PER_DAY.Text = "";
            //txtSMOKING_COUNTS_PER_DAY.Enabled = false;
            ddlDRINK.Text = "";//饮酒
            txtDRINK_ML.Text = "";
            //txtDRINK_ML.Enabled = false;
            txtDRINK_YEAR.Text = "";
            //txtDRINK_YEAR.Enabled = false;
            ddlPAIN.SelectedValue = "";//疼痛
            ddlIN_MIND.Text = "";//心理
            txtIN_MIND_OTHER.Text = "";
            //txtIN_MIND_OTHER.Enabled = false;
            chkLIVING_CONDITION1.Checked = false;//居住状况
            chkLIVING_CONDITION2.Checked = false;
            chkLIVING_CONDITION3.Checked = false;
            chkLIVING_CONDITION4.Checked = false;
            chkLIVING_CONDITION5.Checked = false;
            chkLIVING_CONDITION6.Checked = false;
            txtLIVING_CONDITION_OTHER.Text = "";
            //txtLIVING_CONDITION_OTHER.Enabled = false;
            ddlRELIGIOUS_BELIEF.Text = "";//宗教信仰
            txtRELIGIOUS_BELIEF_OTHER.Text = "";
            //txtRELIGIOUS_BELIEF_OTHER.Enabled = false;
            checkEditfeiyonglaiyuan1.Checked = false; //费用来源-医保
            checkEditfeiyonglaiyuan2.Checked = false; //费用来源-农保
            checkEditfeiyonglaiyuan3.Checked = false; //费用来源-商业保险
            checkEditfeiyonglaiyuan4.Checked = false; //费用来源-工废
            checkEditfeiyonglaiyuan5.Checked = false; //费用来源-自费
            checkEditfeiyonglaiyuan6.Checked = false; //费用来源-其他
            txtCOST_SOURCES_OTHER.Text = "";
            //txtCOST_SOURCES_OTHER.Enabled = false;
            chkSPECIAL_GROUP1.Checked = false;//特殊人群
            chkSPECIAL_GROUP2.Checked = false;
            chkSPECIAL_GROUP3.Checked = false;
            chkSPECIAL_GROUP4.Checked = false;
            chkSPECIAL_GROUP5.Checked = false;
            chkSPECIAL_GROUP6.Checked = false;
            chkSPECIAL_GROUP7.Checked = false;
            chkSPECIAL_GROUP8.Checked = false;
            txtFALL_RISK_ASSESSMENT_SCORE.Text = "";//跌倒风险评估
            chkFALL_RISK_ASSESSMENT_ITEM1.Checked = false;//低风险
            chkFALL_RISK_ASSESSMENT_ITEM2.Checked = false;//高风险
            txtPRESSURE_RISK_ASSESSMENT_SCORE.Text = "";//压疮风险评估
            chkPRESSURE_RISK_ASSESSMENT_ITEM1.Checked = false;
            chkPRESSURE_RISK_ASSESSMENT_ITEM2.Checked = false;
            chkPRESSURE_RISK_ASSESSMENT_ITEM3.Checked = false;
            chkPRESSURE_RISK_ASSESSMENT_ITEM4.Checked = false;
            chkPRESSURE_RISK_ASSESSMENT_ITEM5.Checked = false;
            txtADL_SCORE.Text = "";//ADL
            chkADL_SCORE_ITEM1.Checked = false;
            chkADL_SCORE_ITEM2.Checked = false;
            chkADL_SCORE_ITEM3.Checked = false;
            chkADL_SCORE_ITEM4.Checked = false;
            txtOUT_DATE.Text = "";//出院日期
            txtDISCHARGE_DIAGNOSIS.Text = "";//出院诊断
            txtADL_SCORE_OUT.Text = "";//出院ADL
            chkADL_SCORE_ITEM_OUT1.Checked = false;
            chkADL_SCORE_ITEM_OUT2.Checked = false;
            chkADL_SCORE_ITEM_OUT3.Checked = false;
            chkADL_SCORE_ITEM_OUT4.Checked = false;
            chkWHERE_AFTER_DISCHARGE1.Checked = false;//出院后去向
            chkWHERE_AFTER_DISCHARGE2.Checked = false;
            chkWHERE_AFTER_DISCHARGE3.Checked = false;
            chkWHERE_AFTER_DISCHARGE4.Checked = false;
            chkWHERE_AFTER_DISCHARGE5.Checked = false;
            txtWEIGHT.Text = "";
            txtHEIGHT.Text = "";
            txtTEMPERATURE.Text = "";
            txtPULSE.Text = "";
            txtBREATHING.Text = "";
            txtBLOOD_PRESSURE1.Text = "";
            txtBLOOD_PRESSURE2.Text = "";
        }

        private void btn_reset_Click(object sender, EventArgs e)
        {
            setNull();
        }
        #endregion

        #region 获取压疮风险评估总分、跌倒风险评估总分、ADL评分
        private void getScore()
        {
            //此函数需在所有数据加载完后最后调用
            //跌倒坠床风险评估单(未完成)
            getFRA();
            //压伤风险评估记录单
            getPRA();
            //ADL病人护理分级表
            getADL();
            //出院的adl评分 只有有出院时间才加载出院的相关数据
            if (!string.IsNullOrEmpty(txtOUT_DATE.Text))
                getLastADL();
        }

        //跌倒坠床风险评估单
        private void getFRA()
        {
            string fall_risk_assessment_score = "";//跌倒
            var retFRA = formService.GetNursingFormRecord(Patientinfo[0], Convert.ToInt32(Patientinfo[1]), (int)FormType.FallDown);
            if (retFRA.Code == 1 && retFRA.D != null)
            {
                List<NursingFormRecord> lsFRA = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NursingFormRecord>>(retFRA.D);
                lsFRA.OrderByDescending(a => a.AssessmentDate);
                if (lsFRA.Count > 0)
                {
                    NursingFormRecord rdFra = lsFRA[lsFRA.Count - 1];
                    FallDown ps = XmlUtil.XMLToObject<FallDown>(rdFra.NursingFormData, Encoding.UTF8);
                    if (ps != null)
                    {
                        fall_risk_assessment_score = ps.PingGuXiangMu.ZongFen + "";
                        txtFALL_RISK_ASSESSMENT_SCORE.Text = fall_risk_assessment_score;
                    }
                }
            }
            getCheckFRA(fall_risk_assessment_score);
        }
        //跌倒坠床风险评估单 --风险评估
        private void getCheckFRA(string fall_risk_assessment_score)
        {
            if (!string.IsNullOrEmpty(fall_risk_assessment_score))
            {
                txtFALL_RISK_ASSESSMENT_SCORE.Text = fall_risk_assessment_score;
                int fra_score = int.Parse(fall_risk_assessment_score);
                //先重置所有的复选框
                chkFALL_RISK_ASSESSMENT_ITEM1.Checked = false;
                chkFALL_RISK_ASSESSMENT_ITEM2.Checked = false;
                //再根据值勾上
                if (fra_score <= 7)
                {//低风险
                    chkFALL_RISK_ASSESSMENT_ITEM1.Checked = true;
                }
                if (fra_score >= 8)
                {//高风险
                    chkFALL_RISK_ASSESSMENT_ITEM2.Checked = true;
                }
            }
        }

        //压伤风险评估记录单
        private void getPRA()
        {
            string pressure_risk_assessment_score = "";//压疮
            var retPRA = formService.GetNursingFormRecord(Patientinfo[0], Convert.ToInt32(Patientinfo[1]), (int)FormType.RiskSore);
            if (retPRA.Code == 1 && retPRA.D != null)
            {
                List<NursingFormRecord> lsPRA = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NursingFormRecord>>(retPRA.D);
                lsPRA.OrderByDescending(a => a.AssessmentDate);
                if (lsPRA.Count > 0)
                {
                    NursingFormRecord rdFra = lsPRA[lsPRA.Count - 1];
                    RiskSore ps = XmlUtil.XMLToObject<RiskSore>(rdFra.NursingFormData, Encoding.UTF8);
                    if (ps != null)
                    {
                        pressure_risk_assessment_score = ps.ZongFen + "";
                        txtPRESSURE_RISK_ASSESSMENT_SCORE.Text = pressure_risk_assessment_score;
                    }
                }
            }
            getCheckPRA(pressure_risk_assessment_score);
        }
        //压伤风险评估记录单--风险评估
        private void getCheckPRA(string pressure_risk_assessment_score)
        {
            if (!string.IsNullOrEmpty(pressure_risk_assessment_score))
            {
                txtPRESSURE_RISK_ASSESSMENT_SCORE.Text = pressure_risk_assessment_score;
                int prfa_score = int.Parse(pressure_risk_assessment_score);
                //先重置所有的复选框
                chkPRESSURE_RISK_ASSESSMENT_ITEM1.Checked = false;
                chkPRESSURE_RISK_ASSESSMENT_ITEM2.Checked = false;
                chkPRESSURE_RISK_ASSESSMENT_ITEM3.Checked = false;
                chkPRESSURE_RISK_ASSESSMENT_ITEM4.Checked = false;
                chkPRESSURE_RISK_ASSESSMENT_ITEM5.Checked = false;
                //再根据值勾上
                if (prfa_score >= 19 && prfa_score <= 23)//无风险
                {
                    chkPRESSURE_RISK_ASSESSMENT_ITEM1.Checked = true;
                }
                if (prfa_score >= 15 && prfa_score <= 18)//低危
                {
                    chkPRESSURE_RISK_ASSESSMENT_ITEM2.Checked = true;
                }
                if (prfa_score >= 13 && prfa_score <= 14)//中危
                {
                    chkPRESSURE_RISK_ASSESSMENT_ITEM3.Checked = true;
                }
                if (prfa_score >= 10 && prfa_score <= 12)//高危
                {
                    chkPRESSURE_RISK_ASSESSMENT_ITEM4.Checked = true;
                }
                if (prfa_score <= 9)//极高危
                {
                    chkPRESSURE_RISK_ASSESSMENT_ITEM5.Checked = true;
                }
            }
        }

        //ADL病人护理分级表
        private void getADL()
        {
            string adl_score = "";//第一次护理分级分数
            var retADL = formService.GetNursingFormRecord(Patientinfo[0], Convert.ToInt32(Patientinfo[1]), (int)FormType.PatientCare);
            if (retADL.Code == 1 && retADL.D != null)
            {
                List<NursingFormRecord> lsADL = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NursingFormRecord>>(retADL.D);
                lsADL.OrderByDescending(a => a.AssessmentDate);
                if (lsADL.Count > 0)
                {
                    //获取在院第一条的评分
                    NursingFormRecord rdADL = lsADL[lsADL.Count - 1];
                    NursingGrade ng = XmlUtil.XMLToObject<NursingGrade>(rdADL.NursingFormData, Encoding.UTF8);
                    if (ng != null)
                    {
                        adl_score = ng.ZongFen + "";
                    }
                }
            }
            getCheckADL(adl_score);
        }
        //ADL病人护理分级表 --风险评估
        private void getCheckADL(string adl_score)
        {
            if (!string.IsNullOrEmpty(adl_score))
            {
                chkADL_SCORE_ITEM1.Checked = false;
                chkADL_SCORE_ITEM2.Checked = false;
                chkADL_SCORE_ITEM3.Checked = false;
                chkADL_SCORE_ITEM4.Checked = false;
              
                txtADL_SCORE.Text = adl_score;
                int adl_score_num = int.Parse(adl_score);
                if (adl_score_num == 100)
                {
                    chkADL_SCORE_ITEM1.Checked = true;
                }
                if (adl_score_num >= 61 && adl_score_num <= 99)
                {
                    chkADL_SCORE_ITEM2.Checked = true;
                }
                if (adl_score_num >= 41 && adl_score_num <= 60)
                {
                    chkADL_SCORE_ITEM3.Checked = true;
                }
                if (adl_score_num <= 40)
                {
                    chkADL_SCORE_ITEM4.Checked = true;
                }
            }
        }

        //ADL病人出院评估
        private void getLastADL()
        {
            string last_adl_score = "";//最后一次护理分级分数
            var retADL = formService.GetNursingFormRecord(Patientinfo[0], Convert.ToInt32(Patientinfo[1]), (int)FormType.PatientCare);
            if (retADL.Code == 1 && retADL.D != null)
            {
                List<NursingFormRecord> lsADL = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NursingFormRecord>>(retADL.D);
                lsADL.OrderByDescending(a => a.AssessmentDate);
                if (lsADL.Count > 0)
                {
                    //获取出院最后一条的评分
                    NursingFormRecord rdLastADL = lsADL[0];
                    NursingGrade lastNg = XmlUtil.XMLToObject<NursingGrade>(rdLastADL.NursingFormData, Encoding.UTF8);
                    if (lastNg != null)
                    {
                        last_adl_score = lastNg.ZongFen + "";
                    }
                }
            }
            chkADL_SCORE_ITEM_OUT1.Checked = false;
            chkADL_SCORE_ITEM_OUT2.Checked = false;
            chkADL_SCORE_ITEM_OUT3.Checked = false;
            chkADL_SCORE_ITEM_OUT4.Checked = false;
            if (!string.IsNullOrEmpty(last_adl_score))
            {
                txtADL_SCORE_OUT.Text = last_adl_score;
                int last_adl_score_num = int.Parse(last_adl_score);
                if (last_adl_score_num == 100)
                {
                    chkADL_SCORE_ITEM_OUT1.Checked = true;
                }
                if (last_adl_score_num >= 61 && last_adl_score_num <= 99)
                {
                    chkADL_SCORE_ITEM_OUT2.Checked = true;
                }
                if (last_adl_score_num >= 41 && last_adl_score_num <= 60)
                {
                    chkADL_SCORE_ITEM_OUT3.Checked = true;
                }
                if (last_adl_score_num <= 40)
                {
                    chkADL_SCORE_ITEM_OUT4.Checked = true;
                }
            }
        }
        #endregion

        #region 获取xml下拉框数据源
        /// <summary>
        /// 文化、民族、职业、与患者关系 下拉框赋值
        /// </summary>
        private void GetDDLSource()
        {
            if (this.Patientinfo[0] == null) return;
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc = XmlUtil.GetItems();
            XmlNodeList list = xmlDoc.GetElementsByTagName("Items");
            if (list == null || list.Count == 0) { return; }
            for (int i = 0; i < list.Count; i++)
            {
                int listCount = list[i].ChildNodes.Count;
                if (listCount > 0)//判断是否有子项
                {
                    string itemsKey = list[i].Attributes["key"].Value;//<Items key="卡类型" default="">娶到Items节点中key的值
                    for (int j = 0; j < listCount; j++)
                    {
                        string itemKey = list[i].ChildNodes[j].Attributes["key"].Value;//给需要的下拉框赋值
                        if (itemsKey.Equals("文化程度"))
                        {
                            ddlEducation.Properties.Items.Add(itemKey);//<Item key="医保卡" value="1"/>
                        }
                        if (itemsKey.Equals("民族"))
                        {
                            ddlNationals.Properties.Items.Add(itemKey);
                        }
                        if (itemsKey.Equals("职业"))
                        {
                            ddlJob.Properties.Items.Add(itemKey);
                        }
                        if (itemsKey.Equals("与患者关系"))
                        {
                            ddlPATIENT_RELATION.Properties.Items.Add(itemKey);
                        }
                    }
                }
            }
        }
        #endregion

        #region  获取数据赋值
        private void getRecord()
        {
            if (Patientinfo[0] == null) return;
            //姓名
            txtName.Text = Patientinfo[2];
            //性别
            ddlSex.Text = Patientinfo[3];
            //年龄
            txtAge.Text = Patientinfo[4];
            //病区
            txtArea.Text = Patientinfo[11];
            //科室
            txtDepartment.Text = Patientinfo[9];
            //床号
            txtBedNo.Text = Patientinfo[5];
            //病案号
            txtPatientId.Text = Patientinfo[0];
            
            //入院时间
            txtInDate.Text = Patientinfo[7];
            if (!string.IsNullOrEmpty(txtInDate.Text))
                txtInDate.Text = Convert.ToDateTime(txtInDate.Text).ToString("yyyy-MM-dd HH:mm");
            var ret = formService.GetNursingFormRecord(Patientinfo[0], Convert.ToInt32(Patientinfo[1]), (int)FormType.ZYHZHLPGD);

            if (ret.Code == 1)
            {
                AssessMent assm = new AssessMent();
                List<NursingFormRecord> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NursingFormRecord>>(ret.D);
                if (list.Count > 0)
                {
                    NursingFormRecord record1 = list[list.Count - 1];
                    assm = XmlUtil.XMLToObject<AssessMent>(record1.NursingFormData, Encoding.UTF8);

                    //入院诊断读取 如果xml 有诊断则直接获取诊断 否则获取源诊断
                    if (!string.IsNullOrEmpty(assm.JiBenXinXi.RuYuanZhenDuan))
                    {
                        txtDiagnose.Text = assm.JiBenXinXi.RuYuanZhenDuan;
                    }
                    else
                    {
                        string sql = string.Format("SELECT DIAGNOSE from V_YDHL_PATIENT(NOLOCK) WHERE PATIENT_ID='{0}' AND VISIT_ID='{1}'", Patientinfo[0], Patientinfo[1]);
                        var diagnose = SqlHelper.ExecuteScalar(sql);
                        if (diagnose != DBNull.Value && diagnose != null)
                            txtDiagnose.Text = diagnose.ToString();
                    }

                    //基本信息
                    //入院时间
                    txtInDate.Text = assm.JiBenXinXi.RuYuanShiJian;
                    //入院方式
                    ddlMode.Text = assm.JiBenXinXi.RuYuanFangShi;
                    //体重
                    txtWEIGHT.Text = assm.JiBenXinXi.TiZhong;
                    //身高
                    txtHEIGHT.Text = assm.JiBenXinXi.ShenGao;
                    //名族
                    ddlNationals.Text = assm.JiBenXinXi.MinZu;
                    //籍贯
                    txtNativePlace.Text = assm.JiBenXinXi.JiGuan;
                    //文化程度
                    ddlEducation.Text = assm.JiBenXinXi.WenHuaChengDu;
                    //职业
                    ddlJob.Text = assm.JiBenXinXi.ZhiYe;
                    //婚姻
                    ddlMarriage.Text = assm.JiBenXinXi.HunYin;
                    //联系人
                    txtLinkman.Text = assm.JiBenXinXi.LianXiRen;
                    //与患者关系
                    ddlPATIENT_RELATION.Text = assm.JiBenXinXi.YuHuanZheGuanXi;
                    //联系电话
                    txtPhone.Text = assm.JiBenXinXi.LianXiDianHua;
                    //T            
                    txtTEMPERATURE.Text = assm.JiBenXinXi.T;
                    //P
                    txtPULSE.Text = assm.JiBenXinXi.P;
                    //R
                    txtBREATHING.Text = assm.JiBenXinXi.R;
                    //BP
                    var qiguan = assm.JiBenXinXi.BP.Split('/');
                    txtBLOOD_PRESSURE1.Text = qiguan[0];
                    txtBLOOD_PRESSURE2.Text = assm.JiBenXinXi.BPText;

                    //体征信息
                    //神志
                    ddlMIND.Text = assm.TiZhengXinXi.ShenZhi;
                    txtMIND_OTHER.Text = assm.TiZhengXinXi.ShenZhiText;
                    //慢病史
                    var manbingshiwu = assm.TiZhengXinXi.ManBingShi.Split('#');
                    if (manbingshiwu[0] == "0")
                        checkEditmanbingshi1.Checked = false;
                    else
                        checkEditmanbingshi1.Checked = true;

                    var manbingshigaoxueya = assm.TiZhengXinXi.ManBingShi.Split('#');
                    if (manbingshigaoxueya[1] == "0")
                        checkEditmanbingshi2.Checked = false;
                    else
                        checkEditmanbingshi2.Checked = true;

                    var manbingshiguanxinbing = assm.TiZhengXinXi.ManBingShi.Split('#');
                    if (manbingshiguanxinbing[2] == "0")
                        checkEditmanbingshi3.Checked = false;
                    else
                        checkEditmanbingshi3.Checked = true;

                    var manbingshitangniaobing = assm.TiZhengXinXi.ManBingShi.Split('#');
                    if (manbingshitangniaobing[3] == "0")
                        checkEditmanbingshi4.Checked = false;
                    else
                        checkEditmanbingshi4.Checked = true;

                    var manbingshiqita = assm.TiZhengXinXi.ManBingShi.Split('#');
                    if (manbingshiqita[4] == "0")
                        checkEditmanbingshi5.Checked = false;
                    else
                        checkEditmanbingshi5.Checked = true;

                    txtSLOW_HISTORY_OTHER.Text = assm.TiZhengXinXi.ManBingShiText;
                    //手术史
                    ddlOPERATION_HISTORY.Text = assm.TiZhengXinXi.ShouShuShi;
                    txtOPERATION_HISTORY_OTHER.Text = assm.TiZhengXinXi.ShouShuShiText;
                    //视力
                    var shilizhengchang = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shilizhengchang[0] == "0")
                        checkEditshili1.Checked = false;
                    else
                        checkEditshili1.Checked = true;

                    var shiliruoshi = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shiliruoshi[1] == "0")
                        checkEditshili2.Checked = false;
                    else
                        checkEditshili2.Checked = true;

                    var shilijisnhi = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shilijisnhi[2] == "0")
                        checkEditshili3.Checked = false;
                    else
                        checkEditshili3.Checked = true;

                    var shiliyuanshi = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shiliyuanshi[3] == "0")
                        checkEditshili4.Checked = false;
                    else
                        checkEditshili4.Checked = true;

                    var shilishimingzuo = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shilishimingzuo[4] == "0")
                        checkEditshili5.Checked = false;
                    else
                        checkEditshili5.Checked = true;

                    var shilishimingyou = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shilishimingyou[5] == "0")
                        checkEditshili6.Checked = false;
                    else
                        checkEditshili6.Checked = true;

                    var shiliwufapanduan = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shiliwufapanduan[6] == "0")
                        checkEditshili7.Checked = false;
                    else
                        checkEditshili7.Checked = true;

                    var shiliqita = assm.TiZhengXinXi.ShiLi.Split('#');
                    if (shiliqita[7] == "0")
                        checkEditshili8.Checked = false;
                    else
                        checkEditshili8.Checked = true;

                    txtVISION_OTHER.Text = assm.TiZhengXinXi.ShiLiText;
                    //听力
                    var tinglizhengchang = assm.TiZhengXinXi.TingLi.Split('#');
                    if (tinglizhengchang[0] == "0")
                        checkEdittingli1.Checked = false;
                    else
                        checkEdittingli1.Checked = true;

                    var tingliruoting = assm.TiZhengXinXi.TingLi.Split('#');
                    if (tingliruoting[1] == "0")
                        checkEdittingli2.Checked = false;
                    else
                        checkEdittingli2.Checked = true;

                    var tinglizhuting = assm.TiZhengXinXi.TingLi.Split('#');
                    if (tinglizhuting[2] == "0")
                        checkEdittingli3.Checked = false;
                    else
                        checkEdittingli3.Checked = true;

                    var tinglishicongzuo = assm.TiZhengXinXi.TingLi.Split('#');
                    if (tinglishicongzuo[3] == "0")
                        checkEdittingli4.Checked = false;
                    else
                        checkEdittingli4.Checked = true;

                    var tinglishicongyou = assm.TiZhengXinXi.TingLi.Split('#');
                    if (tinglishicongyou[4] == "0")
                        checkEdittingli5.Checked = false;
                    else
                        checkEdittingli5.Checked = true;

                    var tingliwufapanduan = assm.TiZhengXinXi.TingLi.Split('#');
                    if (tingliwufapanduan[5] == "0")
                        checkEdittingli6.Checked = false;
                    else
                        checkEdittingli6.Checked = true;

                    var tingliqita = assm.TiZhengXinXi.TingLi.Split('#');
                    if (tingliqita[6] == "0")
                        checkEdittingli7.Checked = false;
                    else
                        checkEdittingli7.Checked = true;

                    txtHEARING_OTHER.Text = assm.TiZhengXinXi.TingLiText;
                    //皮肤
                    ddlSKIN.Text = assm.TiZhengXinXi.PiFu;
                    txtSKIN_OTHER.Text = assm.TiZhengXinXi.PiFuText;
                    //过敏史
                    var guominshiweifaxian = assm.TiZhengXinXi.GuoMinShi.Split('#');
                    if (guominshiweifaxian[0] == "0")
                        chkALLERGY_HISTORY.Checked = false;
                    else
                        chkALLERGY_HISTORY.Checked = true;

                    var guominshiyaowu = assm.TiZhengXinXi.GuoMinShi.Split('#');
                    if (guominshiyaowu[1] == "0")
                        chkALLERGY_HISTORY_MEDICINE.Checked = false;
                    else
                        chkALLERGY_HISTORY_MEDICINE.Checked = true;

                    var guominshishiwu = assm.TiZhengXinXi.GuoMinShi.Split('#');
                    if (guominshishiwu[2] == "0")
                        chkALLERGY_HISTORY_FOOD.Checked = false;
                    else
                        chkALLERGY_HISTORY_FOOD.Checked = true;

                    var guominshiqita = assm.TiZhengXinXi.GuoMinShi.Split('#');
                    if (guominshiqita[3] == "0")
                        chkALLERGY_HISTORY_OTHER.Checked = false;
                    else
                        chkALLERGY_HISTORY_OTHER.Checked = true;
                    string yaowu = assm.TiZhengXinXi.GuoMinShiYaoWu;
                    string shiwu = assm.TiZhengXinXi.GuoMinShiShiWu;
                    ddlALLERGY_HISTORY_MEDICINE.Text = yaowu;
                    ddlALLERGY_HISTORY_FOOD.Text = shiwu;
                    if (string.IsNullOrEmpty(yaowu))
                    {
                        ddlALLERGY_HISTORY_MEDICINE.Visible = false;
                        ddlALLERGY_HISTORY_MEDICINE.Text = "";
                    }
                    if (string.IsNullOrEmpty(shiwu))
                    {
                        ddlALLERGY_HISTORY_FOOD.Visible = false;
                        ddlALLERGY_HISTORY_FOOD.Text = "";
                    }
                    txtALLERGY_HISTORY_OTHER.Text = assm.TiZhengXinXi.GuoMinShiQiTa;
                    //食欲
                    ddlDIET_APPETITE.Text = assm.SheHuiPingGu.ShiYu;
                    //方式
                    ddlDIET_MOTHOD.Text = assm.SheHuiPingGu.FangShi;
                    //活动
                    var huodongziru = assm.SheHuiPingGu.HuoDong.Split('#');
                    if (huodongziru[0] == "0")
                        checkEdithuodong1.Checked = false;
                    else
                        checkEdithuodong1.Checked = true;

                    var huodongzhangai = assm.SheHuiPingGu.HuoDong.Split('#');
                    if (huodongzhangai[1] == "0")
                        checkEdithuodong2.Checked = false;
                    else
                        checkEdithuodong2.Checked = true;

                    var huodongzhititanhuanzuoshang = assm.SheHuiPingGu.HuoDong.Split('#');
                    if (huodongzhititanhuanzuoshang[2] == "0")
                        checkEdithuodong3.Checked = false;
                    else
                        checkEdithuodong3.Checked = true;

                    var huodongzhititanhuanzuoxia = assm.SheHuiPingGu.HuoDong.Split('#');
                    if (huodongzhititanhuanzuoxia[3] == "0")
                        checkEdithuodong4.Checked = false;
                    else
                        checkEdithuodong4.Checked = true;

                    var huodongzhititanhuanyoushang = assm.SheHuiPingGu.HuoDong.Split('#');
                    if (huodongzhititanhuanyoushang[4] == "0")
                        checkEdithuodong5.Checked = false;
                    else
                        checkEdithuodong5.Checked = true;

                    var huodongzhititanhuanyouxia = assm.SheHuiPingGu.HuoDong.Split('#');
                    if (huodongzhititanhuanyouxia[5] == "0")
                        checkEdithuodong6.Checked = false;
                    else
                        checkEdithuodong6.Checked = true;

                    var huodongqita = assm.SheHuiPingGu.HuoDong.Split('#');
                    if (huodongqita[6] == "0")
                        checkEdithuodong7.Checked = false;
                    else
                        checkEdithuodong7.Checked = true;
                    comboBoxEdithuodongqita.Text = assm.SheHuiPingGu.HuoDongText;
                    //睡眠
                    ddlSLEEP.Text = assm.SheHuiPingGu.ShuiMian;
                    //排便
                    ddlDEFECATION.Text = assm.SheHuiPingGu.PaiBian;
                    //排尿
                    ddlMICTURITION.Text = assm.SheHuiPingGu.PaiNiao;
                    //吸烟
                    ddlSMOKE.Text = assm.SheHuiPingGu.XiYan;
                    txtSMOKING_COUNTS_PER_DAY.Text = assm.SheHuiPingGu.XiYanZhi;
                    txtSMOKE_YEAR.Text = assm.SheHuiPingGu.XiYanNian;
                    //饮酒
                    string yj = assm.SheHuiPingGu.YinJiu;
                    if (yj == "经常饮酒")
                    {
                        txtDRINK_ML.Visible = true;
                        txtDRINK_YEAR.Visible = true;
                    }
                    ddlDRINK.Text = yj;
                    txtDRINK_ML.Text = assm.SheHuiPingGu.YinJiuMl;
                    txtDRINK_YEAR.Text = assm.SheHuiPingGu.YinJiuNian;
                    //疼痛
                    ddlPAIN.SelectedIndex = !string.IsNullOrEmpty(assm.SheHuiPingGu.TengTong) ? Convert.ToInt32(assm.SheHuiPingGu.TengTong) : 0;
                    //心里
                    ddlIN_MIND.Text = assm.SheHuiPingGu.XinLi;
                    txtIN_MIND_OTHER.Text = assm.SheHuiPingGu.XinLiText;
                    //居住情况
                    var juzhuqingkpeiou = assm.SheHuiPingGu.JuZhuZhuangKuang.Split('#');
                    if (juzhuqingkpeiou[0] == "0")
                        chkLIVING_CONDITION1.Checked = false;
                    else
                        chkLIVING_CONDITION1.Checked = true;

                    var juzhuqingkzimu = assm.SheHuiPingGu.JuZhuZhuangKuang.Split('#');
                    if (juzhuqingkzimu[1] == "0")
                        chkLIVING_CONDITION2.Checked = false;
                    else
                        chkLIVING_CONDITION2.Checked = true;

                    var juzhuqingfumu = assm.SheHuiPingGu.JuZhuZhuangKuang.Split('#');
                    if (juzhuqingfumu[2] == "0")
                        chkLIVING_CONDITION3.Checked = false;
                    else
                        chkLIVING_CONDITION3.Checked = true;

                    var juzhuqingduju = assm.SheHuiPingGu.JuZhuZhuangKuang.Split('#');
                    if (juzhuqingduju[3] == "0")
                        chkLIVING_CONDITION4.Checked = false;
                    else
                        chkLIVING_CONDITION4.Checked = true;

                    var juzhuqingjly = assm.SheHuiPingGu.JuZhuZhuangKuang.Split('#');
                    if (juzhuqingjly[4] == "0")
                        chkLIVING_CONDITION5.Checked = false;
                    else
                        chkLIVING_CONDITION5.Checked = true;

                    var juzhuqingqita = assm.SheHuiPingGu.JuZhuZhuangKuang.Split('#');
                    if (juzhuqingqita[5] == "0")
                        chkLIVING_CONDITION6.Checked = false;
                    else
                        chkLIVING_CONDITION6.Checked = true;

                    txtLIVING_CONDITION_OTHER.Text = assm.SheHuiPingGu.JuZhuZhuangKuangText;
                    //宗教信仰
                    ddlRELIGIOUS_BELIEF.Text = assm.SheHuiPingGu.ZongJiaoXinYang;
                    txtRELIGIOUS_BELIEF_OTHER.Text = assm.SheHuiPingGu.ZongJiaoXinYangText;
                    //费用来源
                    var feiyonglailaiyuanyibao = assm.SheHuiPingGu.FeiYongLaiYuan.Split('#');
                    if (feiyonglailaiyuanyibao[0] == "0")
                        checkEditfeiyonglaiyuan1.Checked = false;
                    else
                        checkEditfeiyonglaiyuan1.Checked = true;

                    var feiyonglailaiyuannongbao = assm.SheHuiPingGu.FeiYongLaiYuan.Split('#');
                    if (feiyonglailaiyuannongbao[1] == "0")
                        checkEditfeiyonglaiyuan2.Checked = false;
                    else
                        checkEditfeiyonglaiyuan2.Checked = true;

                    var feiyonglailaiyuanshangyebaoxian = assm.SheHuiPingGu.FeiYongLaiYuan.Split('#');
                    if (feiyonglailaiyuanshangyebaoxian[2] == "0")
                        checkEditfeiyonglaiyuan3.Checked = false;
                    else
                        checkEditfeiyonglaiyuan3.Checked = true;

                    var feiyonglailaiyuangongfei = assm.SheHuiPingGu.FeiYongLaiYuan.Split('#');
                    if (feiyonglailaiyuangongfei[3] == "0")
                        checkEditfeiyonglaiyuan4.Checked = false;
                    else
                        checkEditfeiyonglaiyuan4.Checked = true;

                    var feiyonglailaiyuanzifei = assm.SheHuiPingGu.FeiYongLaiYuan.Split('#');
                    if (feiyonglailaiyuanzifei[4] == "0")
                        checkEditfeiyonglaiyuan5.Checked = false;
                    else
                        checkEditfeiyonglaiyuan5.Checked = true;

                    var feiyonglailaiyuanqita = assm.SheHuiPingGu.FeiYongLaiYuan.Split('#');
                    if (feiyonglailaiyuanqita[5] == "0")
                        checkEditfeiyonglaiyuan6.Checked = false;
                    else
                        checkEditfeiyonglaiyuan6.Checked = true;

                    txtCOST_SOURCES_OTHER.Text = assm.SheHuiPingGu.FeiYongLaiYuanText;
                    //特殊人群
                    var tsfo = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (tsfo[0] == "0")
                        chkSPECIAL_GROUP1.Checked = false;
                    else
                        chkSPECIAL_GROUP1.Checked = true;

                    var tscq = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (tscq[1] == "0")
                        chkSPECIAL_GROUP2.Checked = false;
                    else
                        chkSPECIAL_GROUP2.Checked = true;

                    var tsfoo = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (tsfoo[2] == "0")
                        chkSPECIAL_GROUP3.Checked = false;
                    else
                        chkSPECIAL_GROUP3.Checked = true;

                    var tsfoooo = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (tsfoooo[3] == "0")
                        chkSPECIAL_GROUP4.Checked = false;
                    else
                        chkSPECIAL_GROUP4.Checked = true;

                    var tsfooooooo = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (tsfooooooo[4] == "0")
                        chkSPECIAL_GROUP5.Checked = false;
                    else
                        chkSPECIAL_GROUP5.Checked = true;

                    var tsfooooo = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (tsfooooo[5] == "0")
                        chkSPECIAL_GROUP6.Checked = false;
                    else
                        chkSPECIAL_GROUP6.Checked = true;

                    var ooo = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (ooo[6] == "0")
                        chkSPECIAL_GROUP7.Checked = false;
                    else
                        chkSPECIAL_GROUP7.Checked = true;

                    var oooo = assm.SheHuiPingGu.TeShuRenQun.Split('#');
                    if (oooo[7] == "0")
                        chkSPECIAL_GROUP8.Checked = false;
                    else
                        chkSPECIAL_GROUP8.Checked = true;

                    //跌到风险评估
                    txtFALL_RISK_ASSESSMENT_SCORE.Text = assm.DieDaoYaChuangADLFengXianPingGu.DieDaoPingGuFenShu;

                    var q = assm.DieDaoYaChuangADLFengXianPingGu.DieDaoPingGu.Split('#');
                    if (q[0] == "0")
                        chkFALL_RISK_ASSESSMENT_ITEM1.Checked = false;
                    else
                        chkFALL_RISK_ASSESSMENT_ITEM1.Checked = true;
                    var qeqw = assm.DieDaoYaChuangADLFengXianPingGu.DieDaoPingGu.Split('#');
                    if (qeqw[1] == "0")
                        chkFALL_RISK_ASSESSMENT_ITEM2.Checked = false;
                    else
                        chkFALL_RISK_ASSESSMENT_ITEM2.Checked = true;

                    //压疮风险评估
                    txtPRESSURE_RISK_ASSESSMENT_SCORE.Text = assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGuFenShu;

                    var qeqqww = assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGu.Split('#');
                    if (qeqw[0] == "0")
                        chkPRESSURE_RISK_ASSESSMENT_ITEM1.Checked = false;
                    else
                        chkPRESSURE_RISK_ASSESSMENT_ITEM1.Checked = true;

                    var ewq = assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGu.Split('#');
                    if (ewq[1] == "0")
                        chkPRESSURE_RISK_ASSESSMENT_ITEM2.Checked = false;
                    else
                        chkPRESSURE_RISK_ASSESSMENT_ITEM2.Checked = true;

                    var eqwe = assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGu.Split('#');
                    if (eqwe[2] == "0")
                        chkPRESSURE_RISK_ASSESSMENT_ITEM3.Checked = false;
                    else
                        chkPRESSURE_RISK_ASSESSMENT_ITEM3.Checked = true;

                    var eqeweqqwe = assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGu.Split('#');
                    if (eqeweqqwe[3] == "0")
                        chkPRESSURE_RISK_ASSESSMENT_ITEM4.Checked = false;
                    else
                        chkPRESSURE_RISK_ASSESSMENT_ITEM4.Checked = true;

                    var sdad = assm.DieDaoYaChuangADLFengXianPingGu.YaChuangPingGu.Split('#');
                    if (sdad[4] == "0")
                        chkPRESSURE_RISK_ASSESSMENT_ITEM5.Checked = false;
                    else
                        chkPRESSURE_RISK_ASSESSMENT_ITEM5.Checked = true;

                    //ADL
                    txtADL_SCORE.Text = assm.DieDaoYaChuangADLFengXianPingGu.ADLPingGuFenShu;

                    var sdqwead = assm.DieDaoYaChuangADLFengXianPingGu.ADLPingGu.Split('#');
                    if (sdqwead[0] == "0")
                        chkADL_SCORE_ITEM1.Checked = false;
                    else
                        chkADL_SCORE_ITEM1.Checked = true;

                    var qeweqw = assm.DieDaoYaChuangADLFengXianPingGu.ADLPingGu.Split('#');
                    if (qeweqw[1] == "0")
                        chkADL_SCORE_ITEM2.Checked = false;
                    else
                        chkADL_SCORE_ITEM2.Checked = true;

                    var eqweqeqw = assm.DieDaoYaChuangADLFengXianPingGu.ADLPingGu.Split('#');
                    if (eqweqeqw[2] == "0")
                        chkADL_SCORE_ITEM3.Checked = false;
                    else
                        chkADL_SCORE_ITEM3.Checked = true;

                    var qweqweqweqwe = assm.DieDaoYaChuangADLFengXianPingGu.ADLPingGu.Split('#');
                    if (qweqweqweqwe[3] == "0")
                        chkADL_SCORE_ITEM4.Checked = false;
                    else
                        chkADL_SCORE_ITEM4.Checked = true;

                    //出院日期
                    txtOUT_DATE.Text = assm.ChuYuanPingGu.ChuYuanRiQi;
                    //出院诊断                    
                    txtDISCHARGE_DIAGNOSIS.Text = assm.ChuYuanPingGu.ChuYuanZhenDuan;
                    //自理能力
                    var das = assm.ChuYuanPingGu.ZiLiNengLi.Split('#');
                    if (das[0] == "0")
                        chkADL_SCORE_ITEM_OUT1.Checked = false;
                    else
                        chkADL_SCORE_ITEM_OUT1.Checked = true;

                    var dsad = assm.ChuYuanPingGu.ZiLiNengLi.Split('#');
                    if (dsad[1] == "0")
                        chkADL_SCORE_ITEM_OUT2.Checked = false;
                    else
                        chkADL_SCORE_ITEM_OUT2.Checked = true;

                    var eqweqw = assm.ChuYuanPingGu.ZiLiNengLi.Split('#');
                    if (eqweqw[2] == "0")
                        chkADL_SCORE_ITEM_OUT3.Checked = false;
                    else
                        chkADL_SCORE_ITEM_OUT3.Checked = true;

                    var czxc = assm.ChuYuanPingGu.ZiLiNengLi.Split('#');
                    if (czxc[3] == "0")
                        chkADL_SCORE_ITEM_OUT4.Checked = false;
                    else
                        chkADL_SCORE_ITEM_OUT4.Checked = true;

                    txtADL_SCORE_OUT.Text = assm.ChuYuanPingGu.ADLPingFen;
                    //出院后去向
                    var sdads = assm.ChuYuanPingGu.ChuYuanHouQuXiang.Split('#');
                    if (sdads[0] == "0")
                        chkWHERE_AFTER_DISCHARGE1.Checked = false;
                    else
                        chkWHERE_AFTER_DISCHARGE1.Checked = true;

                    var sadasdas = assm.ChuYuanPingGu.ChuYuanHouQuXiang.Split('#');
                    if (sadasdas[1] == "0")
                        chkWHERE_AFTER_DISCHARGE2.Checked = false;
                    else
                        chkWHERE_AFTER_DISCHARGE2.Checked = true;

                    var sdadasd = assm.ChuYuanPingGu.ChuYuanHouQuXiang.Split('#');
                    if (sdadasd[2] == "0")
                        chkWHERE_AFTER_DISCHARGE3.Checked = false;
                    else
                        chkWHERE_AFTER_DISCHARGE3.Checked = true;


                    var cfasdf = assm.ChuYuanPingGu.ChuYuanHouQuXiang.Split('#');
                    if (cfasdf[3] == "0")
                        chkWHERE_AFTER_DISCHARGE4.Checked = false;
                    else
                        chkWHERE_AFTER_DISCHARGE4.Checked = true;

                    var sfafasd = assm.ChuYuanPingGu.ChuYuanHouQuXiang.Split('#');
                    if (sfafasd[4] == "0")
                        chkWHERE_AFTER_DISCHARGE5.Checked = false;
                    else
                        chkWHERE_AFTER_DISCHARGE5.Checked = true;

                    //入院护士签名      
                    txtNURSE1.Text = assm.DieDaoYaChuangADLFengXianPingGu.RuYuanHuShiQianMing;
                    //出院护士签名      
                    txtNURSE.Text = assm.ChuYuanPingGu.ChuYuanHuShiQianMing;
                    //入院护士签字-电签
                    es.SetSiginPic(LoginUser.DepartmentCode, assm.DieDaoYaChuangADLFengXianPingGu.RuYuanHuShiQianMing_ID, pictureBox1, txtNURSE1.Location, txtNURSE1);
                    if (txtNURSE1.Text.Equals(this.UserParm[1])) txtNURSE1Id = true;
                    //出院护士签字-电签
                    es.SetSiginPic(LoginUser.DepartmentCode, assm.ChuYuanPingGu.ChuYuanHuShiQianMing_ID, picElectronicSignature, txtNURSE.Location, txtNURSE);
                    if (txtNURSE.Text.Equals(this.UserParm[1])) txtNURSEId = true;
                }
            }
            //对手动更改的总分,重新绑定风险值
            getCheckFRA(txtFALL_RISK_ASSESSMENT_SCORE.Text);
            getCheckPRA(txtPRESSURE_RISK_ASSESSMENT_SCORE.Text);
            getCheckADL(txtADL_SCORE.Text);

            if (string.IsNullOrEmpty(txtFALL_RISK_ASSESSMENT_SCORE.Text) || string.IsNullOrEmpty(txtPRESSURE_RISK_ASSESSMENT_SCORE.Text) || string.IsNullOrEmpty(txtADL_SCORE.Text))
            {
                getScore();// 获取压疮风险评估总分、跌倒风险评估总分、ADL评分
            }
            if (!string.IsNullOrEmpty(txtOUT_DATE.Text))
            {
                getLastADL();
            }

        }

        #endregion

        #region 查询
        private void btn_Query_Click(object sender, EventArgs e)
        {
            setNull();//先全部置空
            getRecord();
        }
        #endregion

        #region 窗体加载
        private void Form1_Load(object sender, EventArgs e)
        {
            getRecord();
        }
        #endregion

        #region 跌倒风险评估单 分数,压疮风险评估单 分数,ADL 分数
        //跌倒风险评估单 分数
        private void btnFALL_RISK_ASSESSMENT_SCORE_Click(object sender, EventArgs e)
        {
            getFRA();
        }
        //压疮风险评估单 分数
        private void btnPRESSURE_RISK_ASSESSMENT_SCORE_Click(object sender, EventArgs e)
        {
            getPRA();
        }
        //ADL 分数
        private void btnADL_SCORE_Click(object sender, EventArgs e)
        {
            getADL();
        }
        //获取出院ADL分数

        private void btnLast_ADL_SCORE_Click(object sender, EventArgs e)
        {
            string str_out_date = txtOUT_DATE.Text;
            if (!string.IsNullOrEmpty(str_out_date))
            {
                getLastADL();
            }
        }
        #endregion

        #region 双击填入护士名字及按钮获取
        //入院护士签名
        bool txtNURSE1Id = false;
        private void txtNURSE1_DoubleClick(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtNURSE1.Text)) return;
            txtNURSE1.Text = LoginUser.UserName;
            txtNURSE1Id = true;
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNURSE1, pictureBox1, txtNURSE1.Location);
        }
        bool txtNURSEId = false;
        //出院护士签名
        private void txtNURSE_DoubleClick(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtNURSE.Text)) return;
            txtNURSE.Text = LoginUser.UserName;
            txtNURSEId = true;
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNURSE, picElectronicSignature, txtNURSE.Location);
        }

        //入院护士签名
        private void ruyuanhushiqianming_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtNURSE1.Text)) return;
            this.txtNURSE1.Text = this.UserParm[1];
            txtNURSE1Id = true;
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNURSE1, pictureBox1, txtNURSE1.Location);
        }
        //出院护士签名
        private void chuyuanhushiqianming_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtNURSE.Text)) return;
            this.txtNURSE.Text = this.UserParm[1];
            txtNURSEId = true;
            es.SearchElectronicSignatureImage(Base.ESSwitch, LoginUser, txtNURSE, picElectronicSignature, txtNURSE.Location);
        }
        #endregion

        #region 获取体温等体征数据 获取按钮事件
        private void BtnPatData_Click(object sender, EventArgs e)
        {
            TemperatureIn x = new TemperatureIn(Patientinfo[0] + "", Patientinfo[1] + "");
            x.ShowDialog();
            if (x.DialogResult == DialogResult.Yes)
            {
                txtTEMPERATURE.Text = x.tiwen;
                txtPULSE.Text = x.maibo;
                txtBREATHING.Text = x.huxi;
                txtBLOOD_PRESSURE1.Text = x.xueya1;
                txtBLOOD_PRESSURE2.Text = x.xueya2;
            }
        }
        #endregion



    }
}
